const puppeteer = require('puppeteer');

(async () => {
    const browser = await puppeteer.launch({headless: false});
    const page = await browser.newPage();
    await page.goto('https://baidu.com'); 
    await page.type('#kw', '小姐姐', {delay: 100}); //打开百度后，自动在搜索框里慢慢输入puppeteer ,
    page.click('#su') //然后点击搜索 
    await page.waitFor(1000);
    const targetLink = await page.evaluate(() => {
        console.log(document.querySelector('.t.c-gap-bottom-small a'))
        let url =  document.querySelector('.t.c-gap-bottom-small a').href

        return url
       
    });
    console.log(targetLink);
    await page.goto(targetLink);
// await page.waitFor(1000); 
    browser.close();
})()